const fs = require('fs');
const path = require('path');

module.exports = (pathName)=>{
    return async (ctx, next)=>{
        if(fs.statSync(pathName).isFile()){
            ctx.body = fs.readFileSync(pathName, 'utf-8');
        } else {
            const path1 = path.join(pathName, './index.html');
            ctx.body = fs.readFileSync(path1, 'utf-8');
        }
        await next();
    }
}